package com.bitoon.basketdudes.jpa;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 * @author PacoFELC 2011
 */
@Entity
@Table(name = "h_visita", schema = "central")
@NamedQueries({
    @NamedQuery(name = "HVisita.findAll"        , query = "SELECT v FROM HVisita v"),
    @NamedQuery(name = "HVisita.findByUsuarioId", query = "SELECT v FROM HVisita v WHERE v.hvisitaPK.usuarioId = :usuario_id and v.hvisitaPK.servicioId = :servicio_id"),
    @NamedQuery(name = "HVisita.findByFecha"    , query = "SELECT v FROM HVisita v WHERE v.hvisitaPK.fecha = :fecha and v.hvisitaPK.usuarioId = :usuario_id and v.hvisitaPK.servicioId = :servicio_id")
})
public class HVisita implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected HVisitaPK hvisitaPK;

    public HVisita() {
    }

    public HVisita(HVisitaPK hvisitaPK) {
        this.hvisitaPK = hvisitaPK;
    }

    public HVisita( int usuarioId, short servicioId, Date fecha) {
        this.hvisitaPK = new HVisitaPK( usuarioId, servicioId, fecha );
    }

    public HVisitaPK getHVisitaPK() {
        return hvisitaPK;
    }

    public void setHVisitaPK(HVisitaPK hvisitaPK) {
        this.hvisitaPK = hvisitaPK;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (hvisitaPK != null ? hvisitaPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof HVisita)) {
            return false;
        }
        HVisita other = (HVisita) object;
        if ((this.hvisitaPK == null && other.hvisitaPK != null) || (this.hvisitaPK != null && !this.hvisitaPK.equals(other.hvisitaPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.bitoon.basketdudes.jpa.HVisita[hvisitaPK=" + hvisitaPK + "]";
    }

}
